#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int n, leg, chicken, rabbit, minAni, maxAni;
	cin >> n;
	while (n--)
	{
		minAni = maxAni = -1;
		cin >> leg;
		for (int i = 0; i <= leg / 2; i++)
		{
			if ((leg + 2 * i) % 4 == 0)
			{
				minAni = (leg + 2 * i) / 4;
				break;
			}
		}
		for (int i = leg / 2; i >= 0; i--)
		{
			if ((leg + 2 * i) % 4 == 0)
			{
				maxAni = (leg + 2 * i) / 4;
				break;
			}
		}
		if (minAni == -1 || maxAni == -1)cout << "0 0" << endl;
		else cout << minAni << " " << maxAni << endl;
	}
	return 0;
}